package org.ysu.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.ysu.common.JsonResult;
import org.ysu.pojo.CCadre;
import org.ysu.pojo.VCadre;
import org.ysu.pojo.Verifier;
import org.ysu.service.CCadreService;
import org.ysu.service.VCadreService;
import org.ysu.service.VerifierService;

@RestController
@RequestMapping("/ccadre")
public class CCadreController {
    @Autowired
    private CCadreService cCadreService;
    @Autowired
    private VCadreService vCadreService;
    @Autowired
    private VerifierService verifierService;

    @GetMapping("/getone/{name}")
    public JsonResult getAllByidNumber(@PathVariable String name){
        JsonResult jsonResult;
        Verifier verifier=verifierService.getByName(name);
        if(verifier==null){
            VCadre vCadre=vCadreService.getByName(name);
            if(vCadre==null){
                jsonResult=new JsonResult(0,"error",null);
            }else{
                jsonResult=new JsonResult(1,"success",vCadre);
            }
        }else{
            jsonResult=new JsonResult(1,"success",verifier);
        }
        return jsonResult;
    }



}
